const minCostClimbingStairs = cost => {
  let n = cost.length
  let p = cost[0], q = cost[1]
  for (let i = 2; i < n; i++) {
    let next = Math.min(p, q) + cost[i]
    p = q
    q = next
  }吧                    
  return Math.min(p, q)
}

console.log(minCostClimbingStairs([1, 100, 1, 1, 1, 100, 1, 1, 100, 1]));